
import { products } from './products';

export const api = {
  getProducts() {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve(products);
      }, 1000);
    })
  },

  buyProducts(cart) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        Math.random() > 0.5 ? resolve(cart) : reject('请求失败');
      }, 1000);
    })
  }

}